import { createRouter, createWebHistory,createWebHashHistory  } from "vue-router";
import routes from './routers.js'
import { getToken } from '../utils/auth.js'

// 路由信息
// const routes = [
    // {
        // path: "/aaa",
        // name: "aaa",
        // component:  () => import('/@/views/test/test.vue'),
    // }
// ];

const router =  createRouter({
  history: createWebHashHistory(), // createWebHashHistory 用#号的形式访问  createWebHistory 
  routes,
})


router.beforeEach((to,name,next)=>{ // 路由钩子判断
	if(to.name == 'DengLuYeMian'||to.name == 'ZhuCeYeMian'){
		next()
	}else{
		if(getToken()){
			next()
		}else{
			next({
				name:'DengLuYeMian'
			})
		}
	}
  
})
export default router